package top.cflwork.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

import top.cflwork.dao.AdverDao;
import top.cflwork.vo.AdverVo;
import top.cflwork.service.AdverService;
import top.cflwork.common.SequenceId;


@Service
public class AdverServiceImpl implements AdverService {
	@Autowired
	private AdverDao adverDao;
    @Autowired
    private SequenceId sequenceId;
	@Override
    @Transactional
	public AdverVo get(String id){
		return adverDao.get(id);
	}
	
	@Override
    @Transactional
	public List<AdverVo> list(AdverVo adverVo){
		return adverDao.list(adverVo);
	}
	
	@Override
    @Transactional
	public long count(AdverVo adverVo){
		return adverDao.count(adverVo);
	}
	
	@Override
    @Transactional
	public int save(AdverVo adver){
	    adver.setId(sequenceId.nextId());
	    return adverDao.save(adver);
	}
	
	@Override
    @Transactional
	public int update(AdverVo adver){
		return adverDao.update(adver);
	}
	
	@Override
    @Transactional
	public int remove(String id){
		return adverDao.remove(id);
	}
	
	@Override
    @Transactional
	public int batchRemove(String[] ids){
		return adverDao.batchRemove(ids);
	}

    @Override
    @Transactional
    public int batchSave(List<AdverVo> adverList){
			adverList.forEach(e -> e.setId(sequenceId.nextId()));
        return adverDao.batchSave(adverList);
    }

	@Override
	@Transactional
	public List<AdverVo> listAlls(){
		return adverDao.listAlls();
	}
}
